package com.nbsaas.boot.order.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "订单优惠券", model = "订单优惠券")
@Entity
@Table(name = "bs_order_coupon")
@Comment("订单优惠券表")
public class OrderCoupon extends AbstractEntity {

    @Comment("订单ID")
    @FormField(title = "订单ID", sortNum = "1", grid = true, required = true)
    @Column(name = "order_id", nullable = false)
    private Long orderId;

    @Comment("订单编号")
    @FormField(title = "订单编号", sortNum = "2", grid = true, required = true)
    @Column(name = "order_no", nullable = false, length = 64)
    private String orderNo;

    @Comment("优惠券ID")
    @FormField(title = "优惠券ID", sortNum = "3", grid = true, required = true)
    @Column(name = "coupon_id", nullable = false)
    private Long couponId;

    @Comment("优惠券名称")
    @FormField(title = "优惠券名称", sortNum = "4", grid = true, required = true)
    @Column(name = "coupon_name", nullable = false, length = 100)
    private String couponName;

    @Comment("优惠券类型")
    @FormField(title = "优惠券类型", sortNum = "5", grid = true, type = InputType.select)
    @Column(name = "coupon_type", nullable = false)
    private Integer couponType;

    @Comment("优惠券面额")
    @FormField(title = "优惠券面额", sortNum = "6", grid = true, type = InputType.el_input_number)
    @Column(name = "coupon_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal couponAmount = BigDecimal.ZERO;

    @Comment("使用门槛金额")
    @FormField(title = "使用门槛金额", sortNum = "7", grid = true, type = InputType.el_input_number)
    @Column(name = "min_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal minAmount = BigDecimal.ZERO;

    @Comment("实际优惠金额")
    @FormField(title = "实际优惠金额", sortNum = "8", grid = true, type = InputType.el_input_number)
    @Column(name = "discount_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal discountAmount = BigDecimal.ZERO;

    @Comment("优惠券编码")
    @FormField(title = "优惠券编码", sortNum = "9", grid = true, required = true)
    @Column(name = "coupon_code", nullable = false, length = 64)
    private String couponCode;

    @Comment("使用状态")
    @FormField(title = "使用状态", sortNum = "10", grid = true, type = InputType.select)
    @Column(name = "use_status", nullable = false)
    private Integer useStatus = 0;
} 